package com.imon.webbox.court.service;

import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import org.springframework.stereotype.Service;

import com.imon.webbox.court.domain.Player;
import com.imon.webbox.court.domain.Reservation;
import com.imon.webbox.court.domain.SportType;

@Service
public class ReservationServiceImpl implements ReservationService {

	public static final SportType TENNIS = new SportType(1, "Tennis");
	public static final SportType FOOTBALL = new SportType(2, "Football");

	List<Reservation> reservations;

	public ReservationServiceImpl() {
		reservations = new ArrayList<Reservation>();
		reservations
				.add(new Reservation("Tennis #1", new GregorianCalendar(2010,
						10, 10).getTime(), 16, new Player("Roger", "N/A"),
						TENNIS));
		reservations
				.add(new Reservation("Tennis #2", new GregorianCalendar(2010,
						10, 10).getTime(), 20, new Player("James", "N/A"),
						TENNIS));
	}

	public List<Reservation> query(String courtName) {
		List<Reservation> reservations = new ArrayList<Reservation>();

		for (Reservation reservation : reservations) {
			if (reservation.getCourtName().equals(courtName)) {
				reservations.add(reservation);
			}
		}

		return reservations;
	}

}
